package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "行为管理")
@RequestMapping("/api/v1")
public class ApBehaviorEntryController {
    @Autowired
    ApLikesBehaviorService apLikesBehaviorService;

    @Autowired
    ApReadBehaviorService apReadBehaviorService;

    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;

    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;

    @Autowired
    ApArticleBehaviorService apArticleBehaviorService;

    /*
    * 保存或取消点赞
    * */
    @ApiOperation("用户点赞或取消点赞")
    @PostMapping("/likes_behavior")
   public ResponseResult likeOrUnLike(@RequestBody @Validated LikesBehaviorDTO dto){
        return apLikesBehaviorService.likeOrHateBehavive(dto);
    }
    /*
    * 阅读行为
    * */
    @ApiOperation("阅读行为保存")
    @PostMapping("/read_behavior")
    public ResponseResult read(@RequestBody @Validated ReadBehaviorDTO dto){
        return apReadBehaviorService.saveReadBehavior(dto);
    }
    /*
    * 喜欢，不喜欢，保存或取消
    * */
    @ApiOperation("喜欢不喜欢行为")
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLikeBehavior(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlike(dto);
    }
    /*
     * 喜欢，不喜欢，保存或取消
     * */
    @ApiOperation("收藏行为")
    @PostMapping("/collection_behavior")
    public ResponseResult collectionBehavior(@RequestBody @Validated CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }
    /*
    *
    * */
    @ApiOperation("查询文章行为")
    @PostMapping("/article/load_article_behavior")
    public ResponseResult loadArtitle(@RequestBody @Validated ArticleBehaviorDTO dto){
        return apArticleBehaviorService.loadApArticle(dto);
    }
}
